//
//  WBNavigationController.swift
//  sinaWebo
//
//  Created by sinaFenQi on 2017/12/6.
//  Copyright © 2017年 sinaFenQi. All rights reserved.
//

import UIKit

class WBNavigationController: UINavigationController {
    override func viewDidLoad() {
        super.viewDidLoad()
//        navigationBar.isHidden = true
        navigationBar.barTintColor = UIColor.cz_color(withHex: 0xf6f6f6)
        
    }
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            
            var title = "返回"
            if let vc = viewController as? WBBaseViewController {
                
                if childViewControllers.count == 1 {
                    title = childViewControllers.first?.title ?? "返回"
                }
                vc.navigationItem.leftBarButtonItem = UIBarButtonItem(title: title, fontSize: 16, target: self, action: #selector(leftBackBut), isBack: true)
            }

        }
        
        super.pushViewController(viewController, animated: true)
    }
    @objc private func leftBackBut() -> () {
        popViewController(animated: true)
    }
}
